package com.example.springboot_demo.controller;

import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@RestController("/hello")
public class InitialController {
    @RequestMapping("/initial")
    @ResponseBody
    public void initial(HttpServletRequest request, HttpServletResponse response) {

        request.setAttribute("name", "熊广");
        try {
            request.getRequestDispatcher("/HomePage.html").forward(request, response);
        } catch (IOException e) {
            throw new RuntimeException(e);
        } catch (ServletException e) {
            throw new RuntimeException(e);
        }
    }
}
